Package-level declarations

Types

Link copied to clipboard
data class BlobEntry(val bytes: ByteArray, val contentType: String?, val etag: String?, val lastModified: Instant?, val responseUrl: String? = null)

One read result from BlobStore.get. Carries the bytes alongside the conditional-fetch metadata that was stored at write time.

Link copied to clipboard
interface BlobStore

URI-keyed binary blob store. Persists arbitrary HTTP-fetched payloads (3D Tiles content, future generic asset caches) under a single content key.

Link copied to clipboard

Mixin for elevation source factories that can fetch one (z, x, y) tile through the cache-then-network pipeline with cache write-through. Implemented by every cached elevation factory — GpkgCachedElevationSourceFactory on JVM, CachedElevationSourceFactory on JS / iOS — so TiledElevationCoverage.launchBulkRetrieval can drive a bulk download without knowing the concrete factory type.

Link copied to clipboard
sealed class CacheCategory<out T : Any>

Typed key for bulk-opening cached content by category. The phantom T carries the return type all the way from the call site through earth.worldwind.util.open, so cm.open(CacheCategory.Tiles) returns List<TiledImageLayer> with no as? cast and no reified type argument at the call site.

Link copied to clipboard
class CachedElevationRef(val factory: CachedElevationSourceFactory, val z: Int, val x: Int, val y: Int)

Per-tile carrier emitted by CachedElevationSourceFactory.createElevationSource. Each platform's retrieveTileArray detects this via elevationSource.asUnrecognized() and dispatches into factory for the actual cache/network + transcoding flow.

Link copied to clipboard
class CachedElevationSourceFactory(backend: ElevationStoreBackend, networkSource: TileSource?, networkDecoder: NetworkBytesDecoder, val outputFormat: String, val isFloat: Boolean, tileMatrixSet: TileMatrixSet, staleAfter: Duration = Duration.INFINITE, revalidationScope: CoroutineScope = GlobalScope) : ElevationSourceFactory, OfflineToggleable, CachedSourceInfoProvider, BulkRetrievableElevationSourceFactory, CacheReadableElevationSourceFactory, RevalidatingSource

Cross-platform ElevationSourceFactory backed by an ElevationStoreBackend + an optional upstream TileSource. Owns the source-format → storage-format transcoding pipeline (encode/decode via ElevationStorageCodec) so platforms (JS, iOS) don't have to reimplement it.

Link copied to clipboard
data class CachedSourceInfo(val contentKey: String, val contentPath: String)

Cache identity for a tile / feature source — the key under which its bytes live in the cache plus the path of the underlying earth.worldwind.util.ContentManager. Layer extensions (TiledImageLayer.cachedSourceInfo, TiledElevationCoverage.cachedSourceInfo, etc.) walk the layer's source chain and return this when the layer is wired through a cache. null means "no cache wired" — the layer is network-only.

Link copied to clipboard

Mixin for cache-aware sources, factories, and stores that can report their underlying CachedSourceInfo. Implementations:

Link copied to clipboard
data class CachedTile(val bytes: ByteArray, val tileScale: Float, val tileOffset: Float, val cachedAt: Long? = null, val etag: String? = null, val lastModified: String? = null)

One stored tile pulled out of an ElevationStoreBackend: the encoded blob plus the per-tile (scale, offset) the codec needs to decode it. cachedAt is the epoch-millis the tile was written (for stale-while-revalidate); null when the backend doesn't track it. etag / lastModified are the stored HTTP validators for a conditional refresh.

Link copied to clipboard

Cache-first decorator over a TiledFeatureSource. On fetchTile:

Link copied to clipboard
class CachedTileSource(inner: TileSource?, store: TileStore, revalidationScope: CoroutineScope = GlobalScope) : TileSource, OfflineToggleable, CachedSourceInfoProvider, RevalidatingSource

Cache-first decorator over a TileSource. The lookup order is:

Link copied to clipboard
data class CacheEntry(val contentKey: String, val dataType: CacheEntry.DataType, val service: WebServiceInfo?, val boundingSector: Sector?, val lastModified: Instant?, val displayName: String = contentKey, val isFloat: Boolean = false)

Metadata about one content entry in the cache — enough for the caller to decide whether to instantiate a layer from it. Produced by ContentManager.listEntries(); the caller turns one of these into a working layer via the reified openLayer<T>(key) / openElevationCoverage<T>(key) helpers (or by manually opening the store + source pair).

Link copied to clipboard
data class CachePolicy(val maxEntries: Long = Long.MAX_VALUE, val staleAfter: Duration = Duration.INFINITE)

One per-content cache policy with two independent facets, threaded into every TileStore / FeatureStore. Defaults are unbounded — callers opt in to each axis.

Link copied to clipboard
interface ContentEntry

Unified "one cached layer's content" view — size on disk, last-modified, clear/delete.

Link copied to clipboard

Cross-platform encode/decode for one elevation tile in the cache.

Link copied to clipboard

Storage backend for one elevation coverage's encoded tiles + their per-tile ancillary (scale, offset) metadata. Per-platform implementations bind one contentKey to the underlying medium:

Link copied to clipboard
sealed class ElevationTileBuffer

Platform-neutral tile-buffer carrier. Concrete sample type stays explicit so the codec doesn't need a platform Buffer abstraction (the existing java.nio.Buffer shape on JVM and Float32Array shape on JS / iOS aren't expect/actual-friendly).

Link copied to clipboard
interface FeatureStore

Persistent backing for cached feature data. Supports both shapes that the source layer may produce:

Link copied to clipboard
class FileSystemFeatureStore(baseDirectory: String, contentKey: String, val cachePolicy: CachePolicy) : FeatureStore, CachedSourceInfoProvider

Filesystem-backed FeatureStore for iOS. One directory per content key under baseDirectory; layout:

Link copied to clipboard
class FileSystemTileStore(baseDirectory: String, contentKey: String, val cachePolicy: CachePolicy) : TileStore, CachedSourceInfoProvider

Filesystem-backed TileStore for iOS. One root directory per content key under baseDirectory; tiles live at ${baseDirectory}/${contentKey}/${z}/${x}/${y}.bin.

Link copied to clipboard
class GpkgBlobStore : BlobStore

GeoPackage-backed BlobStore following the OGC 3D Tiles GeoPackage Extension shape: one SQLite table per dataset, registered in gpkg_contents (data_type='3d-tiles') and gpkg_extensions (gpkg_3d_tiles). Row schema is GpkgBlobRow; the table lifecycle is owned by earth.worldwind.formats.gpkg.GpkgContentManager.openBlobStore.

Link copied to clipboard
class GpkgFeatureStore(geoPackage: GeoPackage, content: GpkgContent, val cachePolicy: CachePolicy = CachePolicy.UNBOUNDED) : FeatureStore, CachedSourceInfoProvider

GeoPackage-backed FeatureStore. One instance binds to one data_type='features' table (identified by content).

Link copied to clipboard
class GpkgTileStore(geoPackage: GeoPackage, content: GpkgContent, val cachePolicy: CachePolicy = CachePolicy.UNBOUNDED) : TileStore, CachedSourceInfoProvider

GeoPackage-backed TileStore. One instance binds to one tile-pyramid table — works for any data_type that uses the tile-user-data shape (image/png, image/jpeg, image/webp, gridded coverages, vector-tile protobuf).

Link copied to clipboard
abstract class HttpTileSource(val headers: Map<String, String> = emptyMap(), connectTimeoutMs: Long = 5.seconds.inWholeMilliseconds, requestTimeoutMs: Long = 30.seconds.inWholeMilliseconds, clientConfig: HttpClientConfig<*>.() -> Unit = {}) : TileSource

Base for TileSource implementations that fetch bytes over HTTP. Owns one lazily-built HttpClient so subclasses only have to provide a URL for (z, x, y).

Link copied to clipboard
class IosContentManager(baseDirectory: String = defaultCachesDirectory()) : ContentManager

Filesystem-backed ContentManager for iOS. Everything persists under baseDirectory (defaults to ~/Library/Caches/worldwind-cache); one top-level directory per content key.

Link copied to clipboard
@RequiresOptIn(level = RequiresOptIn.Level.WARNING, message = "Low-level cache API. Prefer ContentManager.attachCache + openLayer / openElevationCoverage.")
annotation class LowLevelCacheApi

Opt-in marker for low-level cache plumbing on earth.worldwind.util.ContentManager.

Link copied to clipboard
fun interface NetworkBytesDecoder

Platform-specific wire-format decoder used by CachedElevationSourceFactory.fetchTile on cache miss. Each platform implements the same MIME dispatch table (BIL16 / BIL32 / TIFF / DTED → ElevationTileBuffer) — sharing the dispatch in commonMain would mean porting every per-platform decoder kernel here, which buys little vs. the per-platform footprint cost.

Link copied to clipboard

Always-empty store. Used as the earth.worldwind.util.ContentManager.openBlobStore default on platforms that haven't implemented persistence yet, so a layer that opts into caching silently falls back to network-only without crashing.

Link copied to clipboard

Mixin for cache-aware sources / factories that can flip between online and offline modes at runtime. Lets app-level "go offline" walks dispatch generically across CachedTileSource (image / vector / feature pyramids) and the elevation factories (CachedElevationSourceFactory, GpkgCachedElevationSourceFactory).

Link copied to clipboard

A cache-aware source that fires onTileRevalidated — off the render thread — after a stale tile has been re-downloaded and written through (the stale-while-revalidate refresh). The render layer wires this to drop the tile's cached texture / coverage entry and request a redraw, so the freshly-cached bytes appear on-screen without waiting for the next reload.

Link copied to clipboard
class TileSourceFactoryAdapter(val source: TileSource, val imageFormat: String = "image/png") : TileFactory

TileFactory adapter that produces ImageTiles whose imageSource reads bytes from a TileSource. Bridges the rendering pipeline's TileFactory contract (used by earth.worldwind.shape.TiledSurfaceImage for level-set iteration + mip-fallback) onto the cache redesign's source contract.

Link copied to clipboard
interface TileStore

Persistent backing for CachedTileSource — read/write/evict tile blobs keyed by (z, x, y). The store is the cache; CachedTileSource is the cache-aware view that combines a store with an underlying network TileSource.

Link copied to clipboard
class UrlTemplateImageTileSource(val urlTemplate: String, headers: Map<String, String> = emptyMap(), connectTimeoutMs: Long = 5.seconds.inWholeMilliseconds, requestTimeoutMs: Long = 30.seconds.inWholeMilliseconds, clientConfig: HttpClientConfig<*>.() -> Unit = {}) : HttpTileSource

TileSource for slippy-map raster servers — image tiles addressed by (z, x, y) via a URL template, the same pattern every major XYZ-tile provider uses (Google, OSM, MapServer cgi-bin, Stamen, …). Supports the common template tokens {z}, {x}, {y}, {lang}, {rand=a,b,c}, {i} (the WorldWind dialect — see UrlTemplate).

Link copied to clipboard
class WebContentManager(databaseName: String = DEFAULT_DATABASE_NAME) : ContentManager

IndexedDB-backed ContentManager for the JS target. Implements every method of the ContentManager contract — image / vector / coverage tile stores, feature stores (bulk + tile-addressed), and web-service metadata.

Link copied to clipboard
data class WebServiceInfo(val type: String, val address: String, val layerName: String? = null, val outputFormat: String? = null, val metadata: String? = null, val isTransparent: Boolean = false)

Persisted web-service metadata for a cached layer. Stored in the GeoPackage gpkg_web_service extension table so a layer can be reconstructed without contacting the originating server — capabilities XML / JSON in metadata survives across launches.

Properties

Link copied to clipboard

See TiledImageLayer.cachedSourceInfo — same shape for elevation coverages. The cache provider here is the elevation source factory, not a tile-source decorator.

See TiledImageLayer.cachedSourceInfo — same shape for WFS feature layers.

Cache identity of this layer's tile source, or null when the layer isn't wired through a cache (network-only). Walks the layer's tile factory chain, looking for a CachedSourceInfoProvider — typically a CachedTileSource that wraps an IDB / gpkg / filesystem TileStore.

See TiledImageLayer.cachedSourceInfo — same shape for OSM buildings.

See TiledImageLayer.cachedSourceInfo — same shape for MVT vector-tile layers.

Functions

Link copied to clipboard
suspend fun ContentManager.attachCache(layer: TiledImageLayer, contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED)

Register a tiled image layer (WMS / WMTS / WebMercator).

suspend fun ContentManager.attachCache(layer: VectorLayer, contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED)

Register a vector layer. Dispatches by concrete subtype to record the right service-identity row:

suspend fun ContentManager.attachCache(coverage: TiledElevationCoverage, contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED, isFloat: Boolean = false)

Register a tiled elevation coverage.

Link copied to clipboard
actual fun buildTileSourceImageSource(source: TileSource, z: Int, x: Int, y: Int, imageFormat: String): ImageSource

Construct a platform-specific ImageSource backed by source for tile (z, x, y). The platform actual returns an ImageSource.ImageFactory that fetches via TileSource.fetchTile and decodes the resulting bytes (PNG/JPEG/WebP/…) into the platform's native bitmap type.

expect fun buildTileSourceImageSource(source: TileSource, z: Int, x: Int, y: Int, imageFormat: String): ImageSource

Construct a platform-specific ImageSource backed by source for tile (z, x, y). The platform actual returns an ImageSource.ImageFactory that fetches via TileSource.fetchTile and decodes the resulting bytes (PNG/JPEG/WebP/…) into the platform's native bitmap type.

actual fun buildTileSourceImageSource(source: TileSource, z: Int, x: Int, y: Int, imageFormat: String): ImageSource

Construct a platform-specific ImageSource backed by source for tile (z, x, y). The platform actual returns an ImageSource.ImageFactory that fetches via TileSource.fetchTile and decodes the resulting bytes (PNG/JPEG/WebP/…) into the platform's native bitmap type.

actual fun buildTileSourceImageSource(source: TileSource, z: Int, x: Int, y: Int, imageFormat: String): ImageSource

Construct a platform-specific ImageSource backed by source for tile (z, x, y). The platform actual returns an ImageSource.ImageFactory that fetches via TileSource.fetchTile and decodes the resulting bytes (PNG/JPEG/WebP/…) into the platform's native bitmap type.

actual fun buildTileSourceImageSource(source: TileSource, z: Int, x: Int, y: Int, imageFormat: String): ImageSource

Construct a platform-specific ImageSource backed by source for tile (z, x, y). The platform actual returns an ImageSource.ImageFactory that fetches via TileSource.fetchTile and decodes the resulting bytes (PNG/JPEG/WebP/…) into the platform's native bitmap type.

Link copied to clipboard

Elevation-coverage counterpart of TiledImageLayer.contentEntry — coverages have no "self-contained file factory" case in the current factory set, so this is just the ContentManager adapter behind a uniform call site.

One-stop accessor for "this image layer's content view." Lookup order:

Wrap one contentKey inside this ContentManager as a ContentEntry. Mirrors findEntry(key) for read-only inspection plus clearEntry / deleteEntry for lifecycle, behind one uniform surface.

Link copied to clipboard
fun OsmBuildingsLayer.launchBulkRetrieval(sector: Sector, scope: CoroutineScope = GlobalScope, maxRetries: Int = 3, retryTimeoutShort: Duration = 5.seconds, retryTimeoutLong: Duration = 15.seconds, overrideCache: Boolean = false, onProgress: (downloaded: Long, skipped: Long, total: Long) -> Unit? = null): Job

Download every OSM-Buildings feature tile intersecting sector into the layer's feature store — the "save a region for offline use" flow.

fun TiledElevationCoverage.launchBulkRetrieval(sector: Sector, resolution: ClosedRange<Angle>, scope: CoroutineScope = GlobalScope, maxRetries: Int = 3, retryTimeoutShort: Duration = 5.seconds, retryTimeoutLong: Duration = 15.seconds, overrideCache: Boolean = false, onProgress: (downloaded: Long, skipped: Long, total: Long) -> Unit? = null): Job?

Download every elevation tile that intersects sector across every tile matrix whose pixel-resolution falls in resolution, writing each tile through to the coverage's cache.

fun TiledImageLayer.launchBulkRetrieval(sector: Sector, resolution: ClosedRange<Angle>, scope: CoroutineScope = GlobalScope, maxRetries: Int = 3, retryTimeoutShort: Duration = 5.seconds, retryTimeoutLong: Duration = 15.seconds, overrideCache: Boolean = false, onProgress: (downloaded: Long, skipped: Long, total: Long) -> Unit? = null): Job?

Download every tile within sector across the resolution range into the layer's underlying TileStore (when the layer was constructed with a CachedTileSource). Returns the launched Job for cancellation; returns null when the layer's tile factory isn't backed by a TileSourceFactoryAdapter (i.e. no source-based wiring, so bulk-via-source is impossible).

fun MvtVectorLayer.launchBulkRetrieval(sector: Sector, resolution: ClosedRange<Angle>, scope: CoroutineScope = GlobalScope, maxRetries: Int = 3, retryTimeoutShort: Duration = 5.seconds, retryTimeoutLong: Duration = 15.seconds, overrideCache: Boolean = false, onProgress: (downloaded: Long, skipped: Long, total: Long) -> Unit? = null): Job

Download every MVT tile intersecting sector across the resolution range into the layer's vector-tile store — the "save a region for offline use" flow. Takes the same resolution: ClosedRange<Angle> as TiledImageLayer.launchBulkRetrieval (raster) and TiledElevationCoverage.launchBulkRetrieval (elevation) for a uniform bulk API across layer types; the range is mapped to a slippy zoom range via SlippyTiles.zoomForResolution (nearest-neighbor, matching LevelSet.levelForResolution) and clamped to the layer's MvtVectorLayer.minZoom..MvtVectorLayer.maxZoom.

fun TileSource.launchBulkRetrieval(levelSet: LevelSet, sector: Sector, resolution: ClosedRange<Angle>, scope: CoroutineScope = GlobalScope, maxRetries: Int = 3, retryTimeoutShort: Duration = 5.seconds, retryTimeoutLong: Duration = 15.seconds, onProgress: (downloaded: Long, skipped: Long, total: Long) -> Unit? = null): Job

Download every tile that intersects sector across every level whose resolution falls in resolution — typically used by "save a region for offline use" flows. Returns the launched Job so the caller can cancel mid-download.

Link copied to clipboard

See setOfflineOnly on TiledImageLayer. The OfflineToggleable lives on the coverage's elevationSourceFactory (the platform-specific CachedElevationSourceFactory / GpkgCachedElevationSourceFactory both implement it). No-op when the coverage is wired to a network-only factory.

fun TiledImageLayer.setOfflineOnly(offlineOnly: Boolean = true)

Toggle the cache-only flag on a cache-attached layer or coverage.

fun VectorLayer.setOfflineOnly(offlineOnly: Boolean = true)

See setOfflineOnly on TiledImageLayer. Dispatches by VectorLayer subtype to reach the right source field. No-op for unknown subtypes.

Link copied to clipboard

Total number of OSM-Buildings feature tiles launchBulkRetrieval would fetch for sector — the slippy analog of LevelSet.tileCount, for sizing a download before committing to it. Counts a single slippy zoom (OsmBuildingsLayer.tileZoom), the only zoom the renderer reads.

fun MvtVectorLayer.tileCount(sector: Sector, resolution: ClosedRange<Angle>): Long

Total number of MVT tiles launchBulkRetrieval would fetch for sector across the resolution range — the slippy analog of LevelSet.tileCount, for sizing a download before committing to it. Uses the same zoom mapping and clamp as launchBulkRetrieval, so the result matches the total later reported to that call's onProgress.